import csv
import re
import jieba
import jieba.analyse as anls
import pandas as pd

rcsv = open('data/data.csv', 'r', encoding="utf-8")
reader = csv.reader(rcsv)
data = list(reader)
result = []
# 设置显示选项
pd.set_option('display.max_rows', None)
pd.set_option('display.max_columns', None)
for i in range(1, len(data)):
    data0 = {'jobId': data[i][0]}
    if '前端' in data[i][2]:
        data0['job'] = data0.get('job', '') + '/前端'

    if '后端' in data[i][2]:
        data0['job'] = data0.get('job', '') + '/后端'

    if 'Java' in data[i][2] or 'java' in data[i][2] or 'JAVA' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/Java"

    if 'Python' in data[i][2] or 'python' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/Python"

    if 'Html' in data[i][2] or 'HTML' in data[i][2] or 'H5' in data[i][2] or 'h5' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/HTML"

    if 'JavaScript' in data[i][2] or 'JS' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/JavaScript"

    if 'Vue' in data[i][2] or 'vue' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/Vue"

    if '小程序' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/小程序"

    if 'uniapp' in data[i][2] or 'Uniapp' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/uniapp"

    if 'C++' in data[i][2] or 'c++' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/C++"

    if 'C#' in data[i][2] or 'c#' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/C#"

    if 'Linux' in data[i][2] or 'linux' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/Linux"

    if 'Php' in data[i][2] or 'php' in data[i][2] or 'PhP' in data[i][2] or 'PHP' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/php"

    if 'Go' in data[i][2] or 'go' in data[i][2] and 'golang' not in data[i][2] and 'Golang' not in data[i][2]:
        data0['job'] = data0.get('job', '') + "/Go"

    if 'Golang' in data[i][2] or 'golang' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/Golang"

    if 'unity' in data[i][2] or 'Unity' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/Unity"

    if 'android' in data[i][2] or 'Android' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/Android"

    if 'plc' in data[i][2] or 'PLC' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/plc"

    if 'bim' in data[i][2] or 'BIM' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/bim"

    if 'Xpon' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/Xpon"

    if 'fae' in data[i][2] or 'FAE' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/fae"

    if 'layout' in data[i][2] or 'Layout' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/layout"

    if '软件' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/软件类"

    if '硬件' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/硬件类"

    if '研发' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/研发类"

    if '开发' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/开发类"

    if '电子' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/电子类"

    if '通信' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/通信类"

    if '计算机' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/计算机类"

    if '游戏' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/游戏开发类"

    if '大数据' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/大数据类"

    if '信息' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/信息类"

    if '电气' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/电气类"

    if '弱电' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/弱电类"

    if '测试' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/测试类"

    if '嵌入' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/嵌入式开发"

    if '运维' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/运维"

    if '网络' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/网络类"

    if '算法' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/算法类"

    if '专利' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/专利类"

    if '网页' in data[i][2] or '网站' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/网页开发类"

    if '助理' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/助理类"

    if '验证' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/验证类"

    if '实施' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/实施类"

    if '调试' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/调试类"

    if '工艺' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/工艺类"

    if '安装' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/安装类"

    if '服务' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/服务类"

    if '检测' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/检测类"

    if '设备' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/设备类"

    if '工控' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/工控类"

    if '机械' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/机械类"

    if '测绘' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/测绘类"

    if '芯片' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/芯片类"

    if '光学' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/光学类"

    if '物料' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/物料类"

    if '调试' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/调试类"

    if '结构' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/结构类"

    if '物流' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/物流类"

    if '智能' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/智能类"

    if '水电' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/水电类"

    if '上位机' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/上位机类"

    if '节能' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/节能类"

    if '土建' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/土建类"

    if '土木' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/土木类"

    if 'IT' in data[i][2] or '程序员' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/IT类"

    if '销售' in data[i][2] or '售前' in data[i][2] or '售后' in data[i][2] or '售中' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/销售类"

    if '建筑' in data[i][2] or '路' in data[i][2] or '桥' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/建筑类"

    if '系统' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/系统类"

    if '造价' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/造价类"

    if '监理' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/监理类"

    if '维护' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/维护类"

    if '技术' in data[i][2]:
        data0['job'] = data0.get('job', '') + "/技术类"

    # 工作分类
    if '实习' in data[i][2] or '实习' in data[i][5]:
        data0['category'] = data0.get('category', '') + "/实习"

    if '应届' in data[i][2] or '应届' in data[i][5]:
        data0['category'] = data0.get('category', '') + "/应届"

    result.append(data0)

# 定义 CSV 文件路径
csv_file = 'data/job.csv'

# 定义 CSV 文件的表头
header = ['jobId', 'category', 'demand']

# 将结果写入 CSV 文件
with open(csv_file, 'w', newline='', encoding='utf-8') as file:
    writer = csv.writer(file)

    # 写入表头
    writer.writerow(header)

    # 写入数据行
    for row in result:
        writer.writerow([
            row.get('jobId', '未知'),
            row.get('job', '/其它'),
            row.get('category', '/其它')
        ])

print("CSV 文件保存成功！")
